getApp();

var dataProvider = require("../../provider/dataApi.js");

require("../../provider/pipe.js");

Page({
    data: {
        statusBarHeight: "",
        titleBarHeight: "",
        userInfo: "",
        info: {},
        num: 0,
        isloading: !0
    },
    onLoad: function(options) {
        wx.getStorageSync("uid") ? (this.setData({
            statusBarHeight: getApp().globalData.statusBarHeight,
            titleBarHeight: getApp().globalData.titleBarHeight
        }), options = wx.getStorageSync("userinfo"), this.setData({
            userInfo: options
        }), this.medal()) : wx.navigateTo({
            url: "/pages/login/login"
        });
    },
    goBack: function() {
        wx.navigateBack({
            delta: 1
        });
    },
    medal: function() {
        var that = this;
        dataProvider.medal({
            uid: wx.getStorageSync("uid")
        }).then(function(response) {
            if (console.log(response), response.data) {
                var medalCount = 0;
                for (var medal in response.data) 1 == response.data[medal].have && medalCount++;
                that.setData({
                    info: response.data,
                    num: medalCount,
                    isloading: !1
                });
            }
        }).catch(function(error) {
            console.log(error);
        });
    },
    onShareAppMessage: function() {}
});